﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;

namespace MINERP.DAL.InfoConfig
{
    public class PaperTypeDAL:DALBase
    {
        private static ObjectQuery<paperType> GetPaperTypes()
        {
            return DataEntites.paperType; ;
        }


        /// <summary>
        /// Get paperType list
        /// </summary>
        /// <returns></returns>
        public static List<paperType> GetPaperTypeList()
        {
            List<paperType> list = new List<paperType>();
            foreach (paperType paperType in GetPaperTypes())
            {
                list.Add(paperType);
            }
            return list;
        }
        /// <summary>
        /// Get paperType object
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static paperType GetPaperTypeObj(string name)
        {
            return DataEntites.paperType.First(p => p.Name == name);
        }
        /// <summary>
        /// Get paperType object
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static paperType GetPaperTypeObj(int id)
        {
            return DataEntites.paperType.Include("BoardWidth").First(p => p.PaperTypeID ==id);
        }
        /// <summary>
        /// Add paperType
        /// </summary>
        /// <param name="obj"></param>
        public static void Add(paperType obj)
        {
            DataEntites.AddTopaperType(obj);
            DataEntites.SaveChanges();
        }
        /// <summary>
        /// Update paperType
        /// </summary>
        public static void Update()
        {
            DataEntites.SaveChanges();
        }
        /// <summary>
        /// Delete PaperType
        /// </summary>
        /// <param name="obj"></param>
        public static void Delete(paperType obj)
        {
            DataEntites.DeleteObject(obj);
            DataEntites.SaveChanges();
        }
    }
}
